﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TMSimulator
{
    public static class UserManager
    {
        private static Dictionary<string, User> _userIndex = new Dictionary<string, User>();

        public static Dictionary<string, User> UserIndex
        {
            get { return UserManager._userIndex; }
            set { UserManager._userIndex = value; }
        }

      public static bool exists(string username)
        {
            return _userIndex.ContainsKey(username);
        }

      public static User getUser(string username)
        {
            if (exists(username))
            {
                return _userIndex[username];
            }
            return null;
            }

        public static bool addUser(User newUser)
        {
            if (_userIndex.ContainsKey(newUser.Username))
            {
                return false;
            }
            else
            {
                _userIndex.Add(newUser.Username, newUser);
                return true;
            }
        }

        public static int Count()
        {
            return _userIndex.Count;
        }
    }
}
